﻿using AutoMapper;
using MediatR;
using ProcurementManagement.Applcation.Command.QualityCommand;
using ProcurementManagement.Domain.ProcurementDomain;
using ProcurementManagement.Infrstructre.Interface;

namespace ProcurementManagement.Applcation.CommandHanlers.QualityCommandHandler
{
    public class CreateProQCommandHandlers:IRequestHandler<CreateProQCommand,int>
    {

        private readonly IProductQualityRepository _productQualityRepository;
        IMapper _mapper;


        public CreateProQCommandHandlers(IProductQualityRepository productQualityRepository, IMapper mapper)
        {
            _productQualityRepository = productQualityRepository;
            _mapper = mapper;
        }

        public async Task<int> Handle(CreateProQCommand request, CancellationToken cancellationToken)
        {
            return await _productQualityRepository.AddAsync(_mapper.Map<ProductQuality>(request.AddDTO));
        }
    }
}
